package pikes.ecma;

public class IndexedAccess extends PrintableExpression implements IMemberExpression {

	private IMemberExpression memberExpression = null;

	private IExpression indexExpression = null;

	public IndexedAccess(IMemberExpression memberExpression, IExpression indexExpression) {
		super();
		this.memberExpression = memberExpression;
		this.indexExpression = indexExpression;
	}

	public IndexedAccess(IMemberExpression memberExpression, CharSequence indexExpression) {
		this(memberExpression, new Identifier(indexExpression));
	}

	public IndexedAccess(CharSequence identifier, CharSequence indexExpression) {
		this(new Identifier(identifier), new Identifier(indexExpression));
	}

	public void visit(SyntaxTreeVisitor syntaxTreeVisitor) throws EcmaSyntaxVisitingException {
		memberExpression.visit(syntaxTreeVisitor);
		syntaxTreeVisitor.openSquaredBrace();
		indexExpression.visit(syntaxTreeVisitor);
		syntaxTreeVisitor.closeSquaredBrace();
	}

}
